package com.tq.teaching_quality.controller;


import com.tq.teaching_quality.entity.Survey;
import com.tq.teaching_quality.service.SurveyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 问卷 前端控制器
 * </p>
 *
 * @author YTH
 * @since 2020-06-29
 */
@RestController
@RequestMapping("/survey")
public class SurveyController {

    @Autowired
    private SurveyService SurveyService;

    //增加一条记录
    @RequestMapping("/AddSurvey")
    public boolean AddSurvey(@PathVariable("Survey") Survey Survey){
        return SurveyService.save(Survey);
    }

    //删除一条记录
    @RequestMapping("/DeleteSurvey")
    public boolean DeleteSurvey(@PathVariable("SurveyId") Long SurveyId){
        return SurveyService.removeById(SurveyId);
    }

    //查询全部记录
    @RequestMapping("/SelectAllSurvey")
    public List<Survey> SelectAllSurvey(){
        return SurveyService.list();
    }

    //修改一条记录
    @RequestMapping("/UpdateSurvey")
    public boolean UpdateSurvey(@PathVariable("Survey") Survey Survey){
        return SurveyService.updateById(Survey);
    }

}

